package com.ouc.yyi.user.springcloud.user.userInfo.cotroller;

import com.ouc.yyi.user.springcloud.user.userInfo.bo.UserBo;
import com.ouc.yyi.user.springcloud.user.userInfo.feign.CardFeignClient;
import com.ouc.yyi.user.springcloud.user.userInfo.feign.bo.CardBo;
import com.ouc.yyi.user.springcloud.user.userInfo.sevice.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class UserController {

    @Autowired
    private UserInfoService userInfoService;

    @Autowired
    private CardFeignClient cardFeignClient;

    @Value("${server.port}")
    private String port;

    @GetMapping(value = "/user/{id}")
    public CardBo getUserInfoById( @PathVariable("id") String id) {
        System.err.println(port);
        UserBo userInfoById = userInfoService.getUserInfoByOperKey(id);
        Map param = new HashMap();
        param.put("mobile", userInfoById.getMobile());
        CardBo cardInfoByMobile = cardFeignClient.getCardInfoByMobile(param);
        System.err.println("feign的数据:" + cardInfoByMobile);
        System.err.println(userInfoById);
        //return cardInfoByMobile;
        return cardInfoByMobile;
    }

    @GetMapping(value = "/user/hello")
    public String getFeignHello() {
        return cardFeignClient.getHello("hello FeignClient");
    }




}
